#include "MathAndPhysics.h"
#ifndef __Brick_H__
#define __Brick_H__
class Brick
{
	private : 
		static int counter;
		static int orientation;//0:normal 1:leftside=bottom  2:upside down 3:rightside=bottom
		unsigned int gfx;
		int number;

		/*float x;
		float y;
		int offsetX;
		int offsetY;
		float vx;
		float vy;*/
		int mass;
		bool selected;
		int tolerance; //in pixel;
		bool flying;
		
		void regulateCoordinates();
		int width;
		int height;
		Vector2D position;
		Vector2D positionMinus1;
		Vector2D offset;
		Vector2D velocity;

	public :
		Brick(void* _texture, int _width, int _height,int _textureType, int _paletteNumber, int _x, int _y);
		~Brick(){};
		//void tick(float timeElapsed,int stylusX, int stylusY,int velocityX, int velocityY,bool stylusHeld, bool stylusPreviouslyHeld);
		void tick(Vector2D stylusPosition,Vector2D stylusVelocity, bool stylusHeld, bool stylusPreviouslyHeld);
		void tick(float dt,float dtMinus1,Vector2D stylusPosition,Vector2D stylusVelocity, bool stylusHeld, bool stylusPreviouslyHeld);

		bool isFlying();
		bool isUnderStylus(int stylusX, int stylusY, bool useTolerance = false);
		void followStylus(int stylusX, int stylusY);
		void linkToStylus(int stylusX, int stylusY);

		bool isUnderStylus(Vector2D stylus, bool useTolerance);
		void followStylus(Vector2D stylus);
		void linkToStylus(Vector2D stylus);
		void checkCollision(Vector2D& forceSum);

		Vector2D getPosition(){return position;};
		Vector2D getVelocity(){return velocity;};
		int getWidth(){return width;};
		int getHeight(){return height;};
		void getPosition(Vector2D pos){position=pos;};
		void getVelocity(Vector2D vel){velocity=vel;};
		bool collidesWith(float topCornerX,float topCornerY,float _width, float _height);

};
#endif
